package com.skywaregroup.arenal;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

/** Thrown to return a 500 Internal Error response with an error messages in the body. */
public class InternalErrorException extends WebApplicationException
{
	private static final long serialVersionUID = 1L;

    public InternalErrorException()
    {
        this("Original excepton is handled, but request can not be processed.", "Arenal");
    }

    public InternalErrorException(String message, String realm)
    {
        super(Response.status(Status.UNAUTHORIZED).header(HttpHeaders.WWW_AUTHENTICATE,
                                                          "Basic realm=\"" + realm + "\"")
                .entity(message).build());
    }
}
